﻿using AutoMapper;
using MediatR;
using Traceability.App.Api.Read.Application.Command.Trace;
using Traceability.App.Domain.新文件夹;
using Traceability.App.ErrorCode;
using Traceability.App.Intrastructure.Interface;

namespace Traceability.App.Api.Read.Application.Handler.Trace
{
    public class FantHandler : IRequestHandler<FantCommand, ApiResult<TraceabilityModel>>
    {
        private readonly IBaseRepository<TraceabilityModel> traceaRepo;
        private readonly IMapper mapper;

        public FantHandler(IBaseRepository<TraceabilityModel> traceaRepo, IMapper mapper)
        {
            this.traceaRepo = traceaRepo;
            this.mapper = mapper;
        }
        public Task<ApiResult<TraceabilityModel>> Handle(FantCommand request, CancellationToken cancellationToken)
        {
            var res = new ApiResult<TraceabilityModel>();
            var trace = traceaRepo.GetValue(request.Id).Result;
            res.Message = "反填成功";
            res.Code = ApiEnum.Ok;
            res.Data = trace;
            return Task.FromResult(res);
        }
    }
}
